package com.ysd.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ysd.dao.impl.CompanyDaoImpl;
import com.ysd.dao.impl.ImgDaoImpl;
import com.ysd.dao.impl.ProductCategoryDaoImpl;
import com.ysd.entity.Company;
import com.ysd.entity.Img;
import com.ysd.entity.ProductCategory;

public class HeadServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		CompanyDaoImpl cDao = new CompanyDaoImpl();
		Company c = cDao.getCompany();

		request.setAttribute("c", c);
		
		ImgDaoImpl iDao = new ImgDaoImpl();
		List<Img> banner = iDao.getImg();
		request.setAttribute("banner", banner);

		/*
		 * ProductCategoryDaoImpl pCDao = new ProductCategoryDaoImpl();
		 * List<ProductCategory> p = pCDao.getProductCategory();
		 * request.setAttribute("p", p);
		 * 
		 * request.setAttribute("c", c);
		 */

		request.getRequestDispatcher("head.jsp").include(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doGet(request, response);
	}

}
